package com.zeropoint.demo.pojo;


import com.zeropoint.demo.pojo.vo.OperatingIncome;
import com.zeropoint.demo.pojo.vo.PropertyIncome;
import com.zeropoint.demo.pojo.vo.TransferIncome;
import com.zeropoint.demo.pojo.vo.WageIncome;
import lombok.Data;
import lombok.ToString;

/**
 * 家庭收入指标标准化
 */
@ToString
@Data
public class FamilyIncomeStandardized {

    //计算过程
    //总人口
    public int totalPopulation;
    //个体经营类型
    public String selfEmployedType;
    //种植业收入
    public double plantingIncome;
    //养殖业收入
    public double breedingIncome;
    //个体经营年收入
    public double individualBusinessIncome;
    //工资性年收入
    public double annualWageIncome;
    //转移性年收入
    public double annualTransferIncome;
    //财产性年收入
    public double annualPropertyIncome;
    //收入总额
    public double totalRevenue;

    //人均工资性收入
    public double perWageIncome;
    //人均经营性收入
    public double perOperatingIncome;
    //人均转移性收入
    public double perTransferIncome;
    //人均财产性收入
    public double perPropertyIncome;
    //人均收入总额
    public double perIncomeTotal;

    //计算结果
    //人均经营性收入赋值
    public double perOperatingIncomeAssignment;
    //人均工资性收入赋值
    public double perWageIncomeAssignment;
    //人均转移性收入赋值
    public double perTransferIncomeAssignment;
    //人均财产性收入赋值
    public double perPropertyIncomeAssignment;
    //收入赋值
    public double incomeAssignment;

    public FamilyIncomeStandardized(Questionnaire_info info, FormThree formThree){
           totalPopulation = HumanResourceStandardized.totalPopulation;

           selfEmployedType = formThree.operatingIncome.selfEmployed;

           plantingIncome = formThree.operatingIncome.rice*1748
                   +formThree.operatingIncome.corn*651.5
                   +formThree.operatingIncome.vegetables*2000
                   +formThree.operatingIncome.fruit*3200
                   +formThree.operatingIncome.tea*4500;

           breedingIncome = formThree.operatingIncome.cattle*3357.5
                  + formThree.operatingIncome.pig*633.4
                  + formThree.operatingIncome.sheep*369.3
                  + formThree.operatingIncome.chicken*34.3
                  + formThree.operatingIncome.duck*29
                  + formThree.operatingIncome.goose*48
                  + formThree.operatingIncome.fishPonds*15600;

         individualBusinessIncome = formThree.operatingIncome.selfEmployedOucome;

         annualWageIncome = formThree.wageIncome.localFamlyIncome
                 +formThree.wageIncome.otherFamlyIncome;

         annualTransferIncome = formThree.transferIncome.alimony
                 +formThree.transferIncome.forestrySubsidy
                 +formThree.transferIncome.groundSubsidy
                 +formThree.transferIncome.landSubsidies
                 +formThree.transferIncome.livingAllowances
                 +formThree.transferIncome.retirementPay
                 +formThree.transferIncome.scholarship;

         annualPropertyIncome = formThree.propertyIncome.collectiveBonuses
                 +formThree.propertyIncome.depositInterest
                 +formThree.propertyIncome.equityInterest
                 +formThree.propertyIncome.financialDividends
                 +formThree.propertyIncome.landTransferFund
                 +formThree.propertyIncome.realEstateRent;

        totalRevenue = plantingIncome + breedingIncome
                + individualBusinessIncome + annualWageIncome
                + annualTransferIncome + annualPropertyIncome;

        perWageIncome = info.wage_income/totalPopulation;

        perOperatingIncome = info.operational_income/totalPopulation;

        perTransferIncome = info.transfer_income/totalPopulation;

        perPropertyIncome = info.property_income/totalPopulation;

        perIncomeTotal = perWageIncome + perOperatingIncome
                + perTransferIncome + perPropertyIncome;

        if(plantingIncome + breedingIncome + individualBusinessIncome >= info.operational_income){
                 perOperatingIncomeAssignment = 1;
        }else {
                 perOperatingIncomeAssignment = (plantingIncome + breedingIncome + individualBusinessIncome)/info.operational_income;
        }

        if(annualWageIncome >= info.wage_income){
            perWageIncomeAssignment = 1;
        }else {
            perWageIncomeAssignment = annualWageIncome/info.wage_income;
        }

        if(annualTransferIncome >= info.transfer_income){
            perTransferIncomeAssignment = 1;
        }else {
            perTransferIncomeAssignment = annualTransferIncome/ info.transfer_income;
        }

        if(annualPropertyIncome >= info.property_income){
            perPropertyIncomeAssignment = 1;
        }else {
            perPropertyIncomeAssignment = annualPropertyIncome/ info.property_income;
        }

        if(totalRevenue >= perIncomeTotal*totalPopulation){
            incomeAssignment = 1;
        }else {
            incomeAssignment = totalRevenue/(perIncomeTotal*totalPopulation);
        }

    }

    public static void main(String[] args) {
        Questionnaire_info info = new Questionnaire_info();
        info.wage_income = 8684;
        info.operational_income = 6934;
        info.property_income = 90;
        info.transfer_income = 1115;
        FormThree formThree = new FormThree();
        formThree.operatingIncome = new OperatingIncome();
        formThree.operatingIncome.selfEmployedOucome = 12000;
        formThree.wageIncome = new WageIncome();
        formThree.wageIncome.localFamlyIncome = 3000;
        formThree.propertyIncome = new PropertyIncome();
        formThree.transferIncome = new TransferIncome();
        formThree.transferIncome.livingAllowances = 5040;
        HumanResourceStandardized.totalPopulation = 4;
        System.out.println(new FamilyIncomeStandardized(info, formThree));



    }
}
